Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing Extensions and Drivers /
Chapter 5 - Printing Functions for Message Overrides / Using the Printing Functions


Storing and Accessing Data Associated With a Desktop Printer

Applications can store and access information in the data collections that are associated with a specific desktop printer. This allows you to preserve information with the desktop printer that your printing extension or printer driver can use when processing any document.

For example, you could discover that a printer has a color ribbon and store that fact with the desktop printer so that you could report it to the application. Or if the user has set a special option for the printer in the Printing menu, you might want to store that option with the desktop printer so that your driver could use it during printing.

QuickDraw GX provides two functions for interacting with the desktop printer data from within your message overrides. You use the GXWriteDTPData function to store data with the desktop printer, and you use the GXFetchDTPData function to access data that has been stored with the desktop printer.

Listing 5-2 shows the ImageWriter II printer driver's function for determining if the printer has a color ribbon. This function uses the GXFetchDTPData function and returns true if the printer does have a color ribbon.

Listing 5-2 Accessing the desktop printer data

Boolean PrinterHasColorRibbon(gxPrinter thePrinter)
{
   Boolean                 hasColor = true;
   Str32                   deviceName;
   OSErr                   anErr;
   ImageWriterConfigHandle configHandle;
   
   /*
      If not formatting to a particular device, then assume 
      that there is a color ribbon, to allow for the widest
      range of color spaces.
   */
   GXGetPrinterName(thePrinter, deviceName);
   if (deviceName[0] != 0)
      {
      /*
         If formatting for a particular device, then assume that
         there is not a color ribbon because that is more common.
      */
      hasColor = false;
      
      anErr = GXFetchDTPData(deviceName, kImageWriterConfigType,
                  kImageWriterConfigID, &(Handle)configHandle);
      if (anErr == noErr)
         {
         hasColor = (**configHandle).hasColorRibbon;
         DisposHandle((Handle) configHandle);
         }
      }
   
   return(hasColor);
   
}

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help